#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;
const int N = 40, M = 1010;

bool st[N];
int dist[N];
int r[N], cnt[N], q[N], nums[N];
int h[N], e[M], ne[M], w[M], idx;

void add(int a, int b, int c){
    e[idx] = b;
    ne[idx] = h[a];
    w[idx] = c;
    h[a] = idx ++;
}


void build(int c){
    memset(h, -1, sizeof h);
    idx = 0;
    add(0, 24, c); add(24, 0, -c);
    for(int i = 1; i <= 7; i ++){
        add(i + 16, i, r[i] - c);
    }

    for(int i = 8; i <= 24; i ++){
        add(i - 8, i, r[i]);
    }

    for(int i = 1; i <= 24; i ++){
        add(i - 1, i, 0);
        add(i, i - 1, -nums[i]);
    }
}


bool spfa(){
    memset(cnt, 0, sizeof cnt);
    memset(st, 0, sizeof st);
    memset(dist, -0x3f, sizeof dist);
    int hh = 0, tt = 0;
    q[tt++] = 0;
    dist[0] = 0;
    st[0] = true;

    while(hh != tt){
        int t = q[hh ++];
        if(hh == N) hh = 0;
        st[t] = false;

        for(int i = h[t]; ~i; i = ne[i]){
            int j = e[i];
            if(dist[j] < dist[t] + w[i]){
                dist[j] = dist[t] + w[i];
                cnt[j] = cnt[t] + 1;

                if(cnt[j] >= 25) return false;
                if(!st[j]){
                    st[j] = true;
                    q[tt++] = j;
                    if(tt == N) tt = 0;
                }
            }
        }
    }

    return true;

}

void solve(){
    for(int i = 1; i <= 24; i ++){
        scanf("%d", &r[i]);
    }

    int n;
    memset(nums, 0, sizeof nums);
    scanf("%d", &n);
    for(int i = 0; i < n; i ++){
        int x;
        scanf("%d", &x);
        nums[x + 1] ++;
    }

    bool find = false;
    for(int i = 0; i <= 1000; i ++){
        build(i);
        if(spfa()){
            printf("%d\n", i);
            find = true;
            break;
        }
    }

    if(!find){
        printf("No Solution\n");
    }

}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);

    int T;
    scanf("%d", &T);
    while(T--){
        solve();
    }

    return 0;
}